package org.project.product.android.pfe.fanta.adapter;

import java.util.List;

import org.project.product.android.pfe.fanta.data.SqlHelper;
import org.project.product.android.pfe.fanta.domain.Category;
import org.project.product.android.pfe.fanta.domain.Product;
import org.project.product.android.pfe.fanta.domain.User;

import android.content.Context;

public class DataManagerFacade {

	private static DataManagerFacade facade;
	private final SqlHelper helper;

	public static DataManagerFacade getInstance(Context context) {
		if (facade == null) {
			facade = new DataManagerFacade(context);
		}
		return facade;
	}

	private DataManagerFacade(Context context) {
		this.helper = SqlHelper.getInstance(context);
	}

	public List<Category> getCategoryFromLocal() {
		return helper.getCategoryFromLocal();
	}

	public void deleteCategory(Category categorySelected) {
		helper.deleteCategory(categorySelected);
	}

	public long saveCategory(Category categorySelected) {
		return helper.saveCategory(categorySelected);

	}

	public long saveCategory(Category categorySelected, int id) {
		return helper.saveCategory(categorySelected, id);

	}

	public long saveProduct(Product product) {
		return helper.saveProduit(product);

	}

	public List<Product> getProductByCategory(Category categorySelected) {
		return helper.getProductByCategoryFromLocal(categorySelected);
	}

	public void saveUser(User user) {
		helper.saveUser(user);

	}

	public boolean isValidUser(User user) {
		return helper.isValidUser(user);
	}

	public boolean haveAlreadyUserAccount() {
		return helper.haveAlreadyUserAccount();
	}

	public void deleteUser(User userSelected) {
		helper.deleteUser(userSelected);

	}

	public void deleteProduct(Product product) {
		this.helper.deleteProduit(product);
	}

	public Product searchProductByEan(String ean) {
		return this.helper.searchProductByEan(ean);
	}

	public Product searchProductByName(String name) {
		return helper.searchProductByName(name);
	}

	public void deleteProduct(Product product, int quantity) {
		this.helper.deleteProduit(product, quantity);

	}

	public void updateCategory(Category categorySelected) {
		this.helper.updateCategory(categorySelected);
	}

	public User retrieveUserByCodePin(String codePin) {
		return this.helper.retrieveUserByCodePin(codePin);
	}

	public User getListUserFromLocal() {
		return this.helper.getUserFromLocal();
	}

}
